package hackthon.service;

import hackthon.dao.AttendDao;
import hackthon.pojo.Attend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * Created by wuwenhao on 15/1/8.
 */

@Service
public class AttendService {

    @Autowired
    public AttendDao attendDao;

    public int insertAttend(String addressList){
        String list[] = addressList.split(";");
        Attend attend = new Attend();
        System.out.println(list.length);
        attend.setAttend1(null);
        attend.setAttend2(null);
        attend.setAttend3(null);
        attend.setAttend4(null);
        attend.setAttend5(null);
        attend.setAttend6(null);
        attend.setAttend7(null);
        attend.setAttend8(null);
        attend.setAttend9(null);
        attend.setAttend10(null);

        for(int i = 0;i<list.length;i++){
            switch (i){
                case 0: attend.setAttend1(list[i]);break;
                case 1: attend.setAttend2(list[i]);break;
                case 2: attend.setAttend3(list[i]);break;
                case 3: attend.setAttend4(list[i]);break;
                case 4: attend.setAttend5(list[i]);break;
                case 5: attend.setAttend6(list[i]);break;
                case 6: attend.setAttend7(list[i]);break;
                case 7: attend.setAttend8(list[i]);break;
                case 8: attend.setAttend9(list[i]);break;
                case 9: attend.setAttend10(list[i]);break;
                default:;
            }
        }

        attendDao.insertAttend(attend);
        return 1;
    }

}
